package edu.unmsm.fisi.taller2.session3.controller.app;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import edu.unmsm.fisi.taller2.session3.controller.RequestHandler;
import edu.unmsm.fisi.taller2.session3.dao.UserDao;
import edu.unmsm.fisi.taller2.session3.model.UserBean;

public class ShowRecordRequestHandler implements RequestHandler{
	private UserDao userDao;
	
	public ShowRecordRequestHandler() {
		userDao = new UserDao();
	}
	
	@Override
	public String handleResquest(HttpServletRequest request,
			HttpServletResponse response) {
		String name = request.getParameter("name");
		System.out.println("name = "+name);
		if(name==null){
			return "enterName.jsp";
		}else{
			UserBean user = userDao.getUser(name);
			if(user==null){
				return "sorryNotFound.jsp";
			}else {
				request.setAttribute("user", user);
				return "showInfo.jsp";
			}
		}
	}

}
